﻿using Application.Implement;
using Autofac;
using Autofac.Integration.Mvc;
using Facade;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace AutofaceWebApplication1.App_Start
{
    public class Startup
    {
        private static IContainer _container;

        public static T Resolve<T>()
        {
            return _container.Resolve<T>();
        }

        public static void Init()
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<SqlLog>().AsImplementedInterfaces();

            builder.RegisterControllers(Assembly.GetExecutingAssembly());
            builder.RegisterType<LogHelper>();
            _container = builder.Build();
            
            DependencyResolver.SetResolver(new AutofacDependencyResolver(_container));
        }
    }
}
